def primer(num):
    if num < 2:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
    return True
def next_prime(num):
    while True:
        num += 1
        if primer(num):
            return num
words = input().split()
number_str = ""
for word in words:
    if word == "zero":
        number_str += "0"
    elif word == "one":
        number_str += "1"
    elif word == "two":
        number_str += "2"
    elif word == "three":
        number_str += "3"
    elif word == "four":
        number_str += "4"
    elif word == "five":
        number_str += "5"
    elif word == "six":
        number_str += "6"
    elif word == "seven":
        number_str += "7"
    elif word == "eight":
        number_str += "8"
    elif word == "nine":
        number_str += "9"
    elif word == '1' or word == '2' or word == '3' or word == '4' or word == '5' or word == '6' or word == '7' or word == '8' or word == '9':
        print('Wrong input')

num = int(number_str)

print(next_prime(num))

